package io.renren.modules.project.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.project.entity.ConferenceStaffEntity;
import io.renren.modules.project.service.ConferenceStaffService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;




/**
 * 
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-11-27 14:51:06
 */
@RestController
@RequestMapping("/generator/conferencestaff")
public class ConferenceStaffController {
	@Autowired
	private ConferenceStaffService conferenceStaffService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("generator:conferencestaff:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<ConferenceStaffEntity> conferenceStaffList = conferenceStaffService.queryList(query);
		int total = conferenceStaffService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(conferenceStaffList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("generator:conferencestaff:info")
	public R info(@PathVariable("id") String id){
		ConferenceStaffEntity conferenceStaff = conferenceStaffService.queryObject(id);
		
		return R.ok().put("conferenceStaff", conferenceStaff);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("generator:conferencestaff:save")
	public R save(@RequestBody ConferenceStaffEntity conferenceStaff){
		conferenceStaffService.save(conferenceStaff);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("generator:conferencestaff:update")
	public R update(@RequestBody ConferenceStaffEntity conferenceStaff){
		conferenceStaffService.update(conferenceStaff);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("generator:conferencestaff:delete")
	public R delete(@RequestBody String[] ids){
		conferenceStaffService.deleteBatch(ids);
		
		return R.ok();
	}
	/**
	 * 根据userid和会议id修改是否已读
	 */
	@RequestMapping("/conferenceTagging")
	public R conferenceTagging(@RequestBody ConferenceStaffEntity conferenceStaff){
		conferenceStaffService.conferenceTagging(conferenceStaff);
		return R.ok();
	}

	
}
